﻿@using SageKing.Database.EF.Entity.Contracts
@rendermode InteractiveServer

@inherits AuthComponentTabTableBase<TemplateConfigBase,long>

@if (pageData == null)
{
	<Spin size="SpinSize.Large" Tip="Loading..." />
}
else
{
	<Table @ref="table" Class="@tableHeightCssName" ScrollX="@tableScrollX" AutoColIndexes="false"
		   TItem="TemplateConfigBase" DataSource="@pageData.Items" OnExpand="OnRowExpand" OnRowClick="OnRowClick"
		  
		   RowKey="x=>x.Id" Size="TableSize.Small"
		   Loading="tableLoading" ScrollY=@(tableHeight + "px")
		   @bind-SelectedRows="@selectedRows"
		   Resizable Bordered EnableVirtualization
		   HidePagination>

		<TitleTemplate>
			<Space>
				<SpaceItem>
					<Tooltip Title="@IconType.Outline.Up">
						<Button OnClick="(e) => UpRow(selectedRow)" Shape="@ButtonShape.Circle" Icon="@IconType.Outline.Up" />
					</Tooltip>
				</SpaceItem>

				<SpaceItem>
					<Tooltip Title="@IconType.Outline.Down">
						<Button OnClick="(e) => DownRow(selectedRow)" Shape="@ButtonShape.Circle" Icon="@IconType.Outline.Down" />
					</Tooltip>
				</SpaceItem>
			</Space>
		</TitleTemplate>

		<ColumnDefinitions>
			<Selection Type="@selectionType" Width="50"></Selection>
			<GenerateColumns Range="1.." HideColumnsByName="ColumnsByNamesHide" Definitions=DefinitionColumns ShowPropertyInfoFunc="ShowPropertyInfoAction" />


		</ColumnDefinitions>
		<FooterTemplate>
			<Space>
				<SpaceItem>
					<Text Type="TextElementType.Warning">Total: @pageData.Total</Text>
				</SpaceItem>
				<SpaceItem>
					<Text>当前行：@selectedRow?.OrderNo </Text>
					<Text>@selectedRow?.KKey </Text>
					<Text>列名：@(GetTitle(selectedCol))</Text>
				</SpaceItem>
			</Space>
		</FooterTemplate>

	</Table>
}
<style>

	@("." + tableHeightCssName) {
		min-height: @(tableHeight + "px");
		margin: 0;
	}

		@("." + tableHeightCssName) table {
			/* min-height: @(tableHeight - ScrollBarHeight + "px");
			*/ margin: 0;
		}

		@("." + tableHeightCssName) .ant-table-content {
			/* min-height: @(tableHeight + "px");
			*/ margin-right: 5px;
		}
</style>
@code {

}